package com.li.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.li.client.entities.User;
import com.li.client.management.Executor;
import com.li.client.management.LoginManager;
import com.li.client.management.ManagementScreenWidget;
import com.li.client.service.DataUtilityManager;
import com.li.client.util.AppStyle;
import com.li.client.util.StringUtilGwt;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VLayout;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class LibSystem implements EntryPoint {
	public void onModuleLoad() {
		LoginManager loginManager = new LoginManager(new Executor() {
			
			@Override
			public void execute() {
				ManagementScreenWidget msw = new ManagementScreenWidget();
				Canvas layout = msw.getLayout();
				layout.setWidth100();
				layout.setHeight100();
				
				HLayout headerLayout = new HLayout();
				headerLayout.setHeight(AppStyle.px40);
				headerLayout.setLayoutLeftMargin(AppStyle.px5);
				headerLayout.setLayoutRightMargin(AppStyle.px5);
				
				Label spaceLabel = new Label();
				spaceLabel.setWidth(StringUtilGwt.getAsPercentString(AppStyle.px99));
				headerLayout.addMember(spaceLabel);
				
				User user = DataUtilityManager.getCurrentUser();
				Label lable = new Label("Hello, " + user.getFirstName() + ", " + user.getLastName());
				headerLayout.addMember(lable);
				
				
				VLayout mainLayout = new VLayout();
				mainLayout.setWidth100();
				mainLayout.setHeight100();
				mainLayout.addMember(headerLayout);
				mainLayout.addMember(layout);
				
				RootPanel.get().add(mainLayout);
				
			}
		});
		loginManager.show();
	}
}
